////////////////////////////////////////////////////////////////////
//
// File: GenericDAO.java
// Created: 2-mrt-2010 08:08:11
// Author: BBE547 (Maarten Boonen)
// Electrabel n.v./s.a., Regentlaan 8 Boulevard du R�gent, BTW BE 0403.107.701 - 1000 Brussel/Bruxelles, Belgium.
//
// Proprietary Notice:
// This software is the confidential and proprietary information of Electrabel s.a./n.v. and/or its licensors. 
// You shall not disclose this Confidential Information to any third parties
// and any use thereof shall be subject to the terms and conditions of use, as agreed upon with Electrabel in writing.
//
////////////////////////////////////////////////////////////////////
package com.capgemini.expense.dao;

import java.io.Serializable;
import java.util.List;

/**
 * Generic DAO that provides data access methods for a given entity.
 * 
 * @author BBE547 (Maarten Boonen)
 * @param <PK>
 *            type of the primary key
 * @param <E>
 *            type of the entity
 */
public interface GenericDAO<PK extends Serializable, E> {

	/**
	 * Get the entity with the given id.
	 * 
	 * @param id
	 *            identifier for the entity
	 * @return the found entity or null if none exists for the given id
	 */
	E get(PK id);

	/**
	 * Saves the entity in the db or updates it if it already exists.
	 * 
	 * @param entity
	 *            to save or update
	 */
	void saveOrUpdate(E entity);

	/**
	 * Gets all the persisted objects of the supported type
	 * 
	 * @return A list with all persisted objects
	 */
	List<E> getAll();

	/**
	 * @param entity
	 *            the entity to delete
	 */
	void delete(E entity);

}
